// pages/product/detail/index.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
      data:{},
      title:''
    },
    onLoad(options) {
      wx.setNavigationBarTitle({
        title: options.name,
      })
      const data = wx.getStorageSync('caseDetail');
      data.imgList.forEach(i=>{
          if(i.url.indexOf('.mp4')==-1){
              i.type = 'image'
          }else{
              i.type = 'video'
          }
      })
      this.setData({
          data:data,
          title:this.options.name
      })
    },
    preview(e){
        const index = e.currentTarget.dataset.index;
        // wx.previewImage({
        //   urls:[this.data.data.imgList[index].url],
        //   current:index,
        // })
        const sources = this.data.data.imgList.map(i=>{
            return{
               url:i.url,
               type:i.type
            }
        })
        wx.previewMedia({
          sources: sources,
          current:index
        })
    },
    
    onShareAppMessage(){
        console.log(this.data.title,this.data.data.banner.url)
        return {
          title: this.data.title,
          path: '/pages/case/detail/index',
          imageUrl:this.data.data.banner.url
        }
  }
  
    
  })